<template>
  <el-dialog
    title="异常信息"
    :close-on-click-modal="false"
    :visible.sync="visible"
    width="80%"
    @close="dialogClose"
  >
    <el-table :data="dataList" border style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50"
      >
      </el-table-column>
      <el-table-column
        prop="carCode"
        header-align="center"
        align="center"
        label="车牌号"
      >
      </el-table-column>
      <el-table-column
        prop="content"
        header-align="center"
        align="center"
        label="内容"
      >
      </el-table-column>
      <el-table-column
        prop="createdTime"
        header-align="center"
        align="center"
        label="时间"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.createdTime != null">
            {{ scope.row.createdTime | formatDate }}</span
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="page"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="limit"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { formatDate } from "./date";

export default {
  props: {
    ledgerId: {
      type: String,
      default: ""
    }
  },
  components: {},
  data() {
    return {
      dataList: [],
      visible: false,
      page: 1,
      limit: 10,
      totalPage: 0
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {
    console.log(this.ledgerId);
  },
  filters: {
    formatDate(time) {
      time = time;
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd hh:mm");
    }
  },
  methods: {
    init(id) {
      this.visible = true;
      let params = {
        ledgerId: id,
        page: this.page,
        limit: this.limit,
        ledgerId: this.ledgerId
      };
      this.$http({
        url: this.$http.adornUrl(`/generator/bcarledger/alarm/page`),
        method: "post",
        params: this.$http.adornParams(params)
      }).then(({ data }) => {
        this.dataList = data.page.list;
        this.totalPage = data.page.totalCount;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.limit = val;
      this.page = 1;
      this.init();
    },
    // 当前页
    currentChangeHandle(val) {
      this.page = val;
      this.init();
    },
    //关闭回调
    dialogClose() {
      console.log("dia被关闭了");
      this.page = 1;
    }
  }
};
</script>

<style scoped lang="scss"></style>
